home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
awe2-0_1.lha
/
awe2-0.1
/
Src
/
RCS
/
Semaphore.h,v
< prev
next >
Wrap
Text File
|
1989-02-23
|
2KB
|
143 lines
head 3.2;
branch ;
access ;
symbols ;
locks grunwald:3.2; strict;
comment @ * @;
3.2
date 89.02.20.15.37.13; author grunwald; state Exp;
branches ;
next 3.1;
3.1
date 88.12.20.13.50.15; author grunwald; state Exp;
branches ;
next 1.2;
1.2
date 88.10.30.13.06.03; author grunwald; state Exp;
branches ;
next 1.1;
1.1
date 88.09.18.16.42.14; author grunwald; state Exp;
branches ;
next ;
desc
@@
3.2
log
@Start using Gnu library heaps for schedulers
@
text
@// This may look like C code, but it is really -*- C++ -*-
//
// Copyright (C) 1988 University of Illinois, Urbana, Illinois
//
// written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
//
#ifndef SEMAPHOREH
#define SEMAPHOREH
//
// Semaphore.h
//
// This implements a general counting semaphore. Each semaphore has
// a value known as 'count', which can be initialized to any value.
//
// When count is < 1, and a process attempts to reserve the semaphore,
// that process is suspended. If count > 1, then the process continues.
// In either case, the count is decremented.
//
// When releasing a semaphore, the count is incremented. If the count
// was less than 1, a single waiting process (if any is waiting) is
// allowed to proceed.
//
#include "ReserveByException.h"
#include "SpinLock.h"
#include "ThreadContainer.h"
class Semaphore : public ReserveByException {
protected:
SpinLock lock;
ThreadContainer *pScheduler;
int pCount;
private:
virtual bool reserveByException( Thread *byWho );
public :
Semaphore(int count = 1,
ThreadContainer *scheduler = 0,
bool debug = FALSE);
virtual ~Semaphore();
virtual void reserve();
virtual void release();
virtual bool reserveNoBlock();
virtual unsigned size();
//
// You should not change the count when threads are blocked
//
virtual int count();
virtual int count(int count);
virtual void incrCount(int increment);
bool isEmpty();
virtual void classPrintOn(ostream&);
};
inline bool
Semaphore::isEmpty()
{
return( size() == 0);
}
#endif SEMAPHOREH
@
3.1
log
@Steay version
@
text
@d51 4
d57 2
@
1.2
log
@*** empty log message ***
@
text
@@
1.1
log
@Initial revision
@
text
@d1 6
d26 1
a26 1
#include "HardSpinLock.h"
d32 1
a32 1
HardSpinLock lock;
@